<%@page import="com.railway.msg.model.*"%>
<%@ page contentType="text/html;charset=UTF-8"%>
<%@ include file="/commons/taglibs.jsp"%>
<html>

	<head>
		<link rel="stylesheet" href="${ctx}/css/ztree.css" type="text/css">
		<link rel="stylesheet" href="${ctx}/css/zTreeStyle/zTreeStyle.css"
			type="text/css">
		<link href="${ctx}/commons/upload/css/uploadify.css" rel="stylesheet"
			type="text/css" />
		<script type="text/javascript"
			src="${ctx}/scripts/jquery-1.4.2.min.js"></script>
		<script type="text/javascript"
			src="${ctx}/scripts/jquery.easyui.min.js"></script>
		<script type="text/javascript"
			src="${ctx}/scripts/locale/easyui-lang-zh_CN.js"></script>
		<script type="text/javascript"
			src="${ctx}/scripts/jquery-1.4.4.min.js"></script>
		<script type="text/javascript"
			src="${ctx}/commons/upload/js/swfobject.js"></script>
		<script type="text/javascript"
			src="${ctx}/commons/upload/js/jquery.uploadify.v2.1.4.js"></script>
		<script type="text/javascript"
			src="${ctx}/scripts/jquery.ztree.core-3.0.min.js"></script>
		<script type="text/javascript"
			src="${ctx}/scripts/jquery.ztree.excheck-3.0.min.js"></script>

		<script type="text/javascript"> 
	  var tempid;
	  var tempname;
 
      function getReturnValue() {    
                var a=new Array(tempid,tempname);
               window.returnValue = a  
               window.close();  

       }  
	var setting = {
			check: {
				enable: true,
				chkboxType: { "Y" : "ps", "N" : "ps" }
			},
			view: {
				dblClickExpand: false
			},
			data: {
				simpleData: {
					enable: true
				}
			},
			callback: {
				beforeClick: beforeClick,
				onCheck: onCheck
			}
		};


     
		function beforeClick(treeId, treeNode) {
			var zTree = $.fn.zTree.getZTreeObj("treeDemo");
			zTree.checkNode(treeNode, !treeNode.checked, null, true);
			return false;
		}
		
		function onCheck(e, treeId, treeNode) {

			var zTree = $.fn.zTree.getZTreeObj("treeDemo"),
			nodes = zTree.getCheckedNodes(true),
			v = "";
	
			for (var i=0, l=nodes.length; i<l; i++) {
				if(nodes[i].type == 1){
				var tt = nodes[i].id;
		     	form1.targetids.value +=   tt.substring(1,tt.length) + ",";
				v += nodes[i].name + ",";}
			}
			if (v.length > 0 ) v = v.substring(0, v.length-1);
			var cityObj = $("#citySel");
			cityObj.attr("value", v);
			getReturnValue();
		}

		function showMenu() {
			var cityObj = $("#citySel");
			
			var cityOffset = $("#citySel").offset();
			
			$("#menuContent").css({left:cityOffset.left + "px", top:cityOffset.top + cityObj.outerHeight() + "px"}).slideDown("fast");

			$("body").bind("mousedown", onBodyDown);
		}
		function hideMenu() {
			$("#menuContent").fadeOut("fast");
			$("body").unbind("mousedown", onBodyDown);
		}
		function onBodyDown(event) {
			if (!(event.target.id == "menuBtn" || event.target.id == "citySel" || event.target.id == "menuContent" || $(event.target).parents("#menuContent").length>0)) {
				hideMenu();
			}
		}
	        $(document).ready(function() {        	        
	            $.get("${ctx}/system/SysUser/getUserDept.do", {
	            
                Action:"get",Name:"user01"}, function (data, textStatus){		

             var zNodes = eval(data);
			//var zNodes =[
			//{"id":"1", "pId":"0", "name":"部门01", "open":"true", nocheck:false;,"type":"0"},
			//{"id":"11", "pId":"1", "name":"人员01","type":"1"},
			//{"id":"12", "pId":"1", "name":"人员02","type":"1"},
			//{"id":"13", "pId":"1", "name":"人员03","type":"1"}];
              
                $.fn.zTree.init($("#treeDemo"), setting, zNodes);
                
				});	
	        	
	            $("#fileupload").uploadify({
	           
	                 'allBytesLoaded':300 * 1024*1024,
	                /*注意前面需要书写path的代码*/ 
	                'uploader'       : '${ctx}/commons/upload/js/uploadify.swf', 
	                'script'         : '${ctx}/files/Files/upload.do', 
	                'cancelImg'      : '${ctx}/commons/upload/images/cancel.png', 
	                'queueID'        : 'fileQueue', //和存放队列的DIV的id一致 
	                'fileDataName'   : 'fileupload', //和以下input的name属性一致 
	                'auto'           : false, //是否自动开始 
	                'multi'          : false, //是否支持多文件上传 
	                'buttonText'     : '选择文件', //按钮上的文字 
	                'simUploadLimit' : 1, //一次同步上传的文件数目 
	                'sizeLimit'      : 30* 1024 * 1024, //设置单个文件大小限制 
	                'queueSizeLimit' : 1, //队列中同时存在的文件个数限制 
	                'fileDesc'       : '支持格式:jpg/gif/jpeg/png/bmp.', //如果配置了以下的'fileExt'属性，那么这个属性是必须的 
	                'fileExt'        : '*.zip;*.flv;*.jpg;*.gif;*.jpeg;*.png;*.bmp',//允许的格式   
	            onComplete: function (event, queueID, fileObj, response, data) { 
      			     var objs = eval("["+response+"]");	               
	                 form1.uploadedfileid.value = objs[0].uploadedfileid;            
	              
					$('<li></li>').appendTo('.files').text(objs[0].uploadedresult); 
	}, 
	onError: function(event, queueID, fileObj) { 
	             alert("文件:" + fileObj.name + "上传失败"); 
	       }, 
	       onCancel: function(event, queueID, fileObj){ 
	       alert("取消了" + fileObj.name); 
	       } 
	            }); 
	
	        }); 
	        </script>




	</head>
	<body>

		<div class="content_wrap">
			<div class="zTreeDemoBackground left">
				<ul class="list">
					<li class="title">
						&nbsp;&nbsp;
						<span class="highlight_red"><a id="menuBtn" href="#"
							onclick="showMenu(); return false;">选择</a>或手工输入(逗号分隔)</span>
					</li>
					<li class="title">
						<textarea id="citySel" type="text" value="" onclick="showMenu();"
							rows="5" cols="80" style="width: 180px"></textarea>

					</li>
				</ul>
			</div>
			<div class="right">


		<div id="menuContent" class="menuContent"
			style="display: none; position: absolute;">
			<ul id="treeDemo" class="ztree"
				style="margin-top: 0; width: 180px; height: 300px;"></ul>
		</div>
	</body>
	<script>
//begin $(document).ready(handler)
$(function(){
$('#form1').submit(function(){
	//return $('#form1').form('validate');
});}
);//end $(document).ready(handler)
</script>
</html>

